package cn.hp.controller;

import cn.hp.entity.UserRole;
import cn.hp.service.UserRoleService;
import cn.hp.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("/api/userRole")
public class UserRoleController {
    @Autowired
    private UserRoleService userRoleService;

    @GetMapping("/getUserRole")
    public Result findUserRole(UserRole userRole) {
        List<UserRole> list = userRoleService.selectUserRol(userRole);
        Integer[] roleIds = new Integer[list.size()];
        for (int i = 0; i < list.size(); i++) {
            roleIds[i] = list.get(i).getRoleId();
        }
        return Result.success(roleIds);
    }

}
